﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/MainSite.Master"
    AutoEventWireup="true" CodeBehind="Precios.aspx.cs" Inherits="ShoppingCart.WebSite.Admin.Precios" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cpHead" runat="server">

    <script type="text/javascript">
        function selectAll(invoker) {
            var inputElements = document.getElementsByTagName('input');
            for (var i = 0; i < inputElements.length; i++) {
                var myElement = inputElements[i];
                if (myElement.type === "checkbox") {
                    myElement.checked = invoker.checked;
                }
            }
        } 
    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpContent" runat="server">
    <div class="block">
        <div class="block_head">
            <div class="bheadl">
            </div>
            <div class="bheadr">
            </div>
            <h2>
                Asignacion de Precios y Stock</h2>
        </div>
        <div class="block_content">
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr valign="top">
                    <td>
                        <b>Buscar Producto: </b>
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlProductos" runat="server" Width="350px" AutoPostBack="True"
                            OnSelectedIndexChanged="DdlProductosSelectedIndexChanged">
                        </asp:DropDownList>
                    </td>
                </tr>
            </table>
            <asp:UpdatePanel ID="upnActualizar" runat="server">
                <ContentTemplate>
                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td width="230" style="vertical-align: top;">
                                <table border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                        <th>
                                            CODIGO:
                                        </th>
                                        <th>
                                            <asp:Literal ID="litIdProducto" runat="server"></asp:Literal>
                                        </th>
                                    </tr>
                                    <tr>
                                        <td width="70">
                                            <b>NOMBRE:</b>
                                        </td>
                                        <td>
                                            <asp:Literal ID="litNombre" runat="server"></asp:Literal>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td width="70">
                                            <b>LINEA:</b>
                                        </td>
                                        <td>
                                            <asp:Literal ID="litLinea" runat="server"></asp:Literal>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td width="70">
                                            <b>ESTADO</b>:
                                        </td>
                                        <td>
                                            <asp:Literal ID="litEstado" runat="server"></asp:Literal>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="2" align="center">
                                            <asp:Image ID="imgIcono" runat="server" Height="130px" Width="190px" ImageAlign="Middle" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="2">
                                            <div style="float: left;">
                                                <asp:HyperLink ID="hlkEditar" runat="server" NavigateUrl="~/Admin/Precios.aspx">
                                            <img src="Style/images/edit.jpg" alt="Editar" border="0" /> Modificar</asp:HyperLink>
                                            </div>
                                            <div style="float: right;">
                                                <asp:Button ID="btnGuardar" runat="server" Text="GUARDAR" Width="100px" OnClick="BtnGuardarClick" />
                                            </div>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                            <td width="500" style="vertical-align: top;">
                                <asp:GridView ID="gvPrecios" runat="server" AutoGenerateColumns="False" EmptyDataText="No existen puntos de venta en los departamentos."
                                    GridLines="None" Width="100%">
                                    <Columns>
                                        <asp:BoundField DataField="IdDepartamento" />
                                        <asp:BoundField HeaderText="DEPARTAMENTO" DataField="Departamento" ItemStyle-Width="220px">
                                            <ItemStyle Width="230px" />
                                        </asp:BoundField>
                                        <asp:TemplateField HeaderText="STOCK">
                                            <ItemTemplate>
                                                <asp:TextBox ID="txtStock" runat="server" Text='<%# Eval("Stock") %>' Width="90px"></asp:TextBox>
                                                <asp:RequiredFieldValidator ID="rfvStock" runat="server" ControlToValidate="txtStock"
                                                    ErrorMessage="*" SetFocusOnError="true" Display="Dynamic"></asp:RequiredFieldValidator>
                                                <asp:RangeValidator ID="rgvStock" runat="server" ErrorMessage="*" ControlToValidate="txtStock"
                                                    Display="Dynamic" MaximumValue="100000" MinimumValue="0" SetFocusOnError="true"
                                                    ToolTip="Formato incorrecto" Type="Integer"></asp:RangeValidator>
                                            </ItemTemplate>
                                            <ItemStyle Width="100px" />
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="PRECIO">
                                            <ItemTemplate>
                                                <asp:TextBox ID="txtPrecio" runat="server" Text='<%# Eval("Precio") %>' Width="90px"></asp:TextBox>
                                                <asp:RequiredFieldValidator ID="rfvPrecio" runat="server" ControlToValidate="txtPrecio"
                                                    ErrorMessage="*" SetFocusOnError="true" Display="Dynamic"></asp:RequiredFieldValidator>
                                                <asp:RangeValidator ID="rgvPrecio" runat="server" ErrorMessage="*" ControlToValidate="txtPrecio"
                                                    Display="Dynamic" MaximumValue="100000" MinimumValue="0" SetFocusOnError="true"
                                                    ToolTip="Formato incorrecto" Type="Currency"></asp:RangeValidator>
                                            </ItemTemplate>
                                            <ItemStyle Width="100px" />
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="ESTADO">
                                            <HeaderTemplate>
                                                <asp:CheckBox ID="ckbEstadoAll" runat="server" Text="" ToolTip="Marcar/Desmarcar Todos"
                                                    OnClick="selectAll(this)" />
                                            </HeaderTemplate>
                                            <ItemTemplate>
                                                <asp:CheckBox ID="ckbEstado" runat="server" Checked='<%# Eval("Estado") %>' />
                                            </ItemTemplate>
                                            <ItemStyle Width="40px" />
                                        </asp:TemplateField>
                                    </Columns>
                                    <RowStyle Height="30px" />
                                    <FooterStyle CssClass="pagination" />
                                    <HeaderStyle HorizontalAlign="Center" />
                                </asp:GridView>
                                <div id="divPrecio" runat="server" visible="false">
                                    <table>
                                        <tr>
                                            <td>
                                                <b>Precio General: </b>
                                            </td>
                                            <td style="width: 130px;">
                                                <asp:TextBox ID="txtPrecioGeneral" runat="server" ValidationGroup="PrecioGeneral"
                                                    Width="100px"></asp:TextBox>
                                                <asp:RequiredFieldValidator ID="rfvPrecio" runat="server" ControlToValidate="txtPrecioGeneral"
                                                    ErrorMessage="*" SetFocusOnError="true" Display="Dynamic" ValidationGroup="PrecioGeneral"></asp:RequiredFieldValidator>
                                                <asp:RangeValidator ID="rgvPrecio" runat="server" ErrorMessage="*" ControlToValidate="txtPrecioGeneral"
                                                    Display="Dynamic" MaximumValue="100000" MinimumValue="0" SetFocusOnError="true"
                                                    ToolTip="Formato incorrecto" Type="Currency" ValidationGroup="PrecioGeneral"></asp:RangeValidator>
                                            </td>
                                            <td>
                                                <asp:Button ID="btnAsignar" runat="server" Text=" Asignar " ToolTip="Asignar" ValidationGroup="PrecioGeneral"
                                                    OnClick="BtnAsignarClick" />
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                            </td>
                        </tr>
                    </table>
                    <asp:Literal ID="litMensaje" runat="server"></asp:Literal>
                    <br />
                </ContentTemplate>
                <Triggers>
                </Triggers>
            </asp:UpdatePanel>
        </div>
        <div class="bendl">
        </div>
        <div class="bendr">
        </div>
    </div>
</asp:Content>
